﻿<!--#include file="inc/common.asp" -->
<%
'处理trackback ping的功能模块
'
'author: evan zhao
'

call openDB

response.contentType="text/xml"


dim blog_id, track_id, content_id, url, title, excerpt, user_name, user_id, host_name, host_url
dim err_msg
err_msg = "service unavaliable"
%><?xml version="1.0" encoding="<%=DEFAULT_CHARSET%>"?>
<%
if request("__mode=rss")<>"" then
%>
<response>
<error>0</error>
<rss version="0.91">
<channel>
<title>TrackBack Test</title>
<link>http://<%=baseURL%></link>
<description></description>
<language>zh-cn</language>
<item>
<title>TrackBack Demo</title>
<link>http://<%=baseURL%></link>
<description>not support</description>
</item>
</channel>
</rss></response>


<%
    response.end
end if


content_id = trim(request("content_id"))
if content_id="" then
    content_id = trim(request("cid"))
end if

if content_id="" then
    err_msg = ("请提供原文ID(content_id); ")
else
    content_id=clng(content_id)    
end if

url = filterHTML(request.form("url"))
if url="" then
    url = filterHTML(request.queryString("url"))
end if    
if url="" then
    err_msg = ("请提供URL(url); ")
end if

title = filterHTML(request("title"))
if title="" then
    title = url
end if    

'host_url = filterHTML(request("blog_url"))

host_name = filterHTML(request("blog_name"))

excerpt = filterHTML(request("excerpt"))

if err_msg="" and  userRightObj.canReply  then
      dim blogItem
      set blogItem = new BlogItemClass
      blogItem.load(content_id)  
      
      blog_id=blogItem.blogId
      
      sql = "select track_id, blog_id, content_id,  url, title, excerpt, user_name, user_id, host_name, host_url from blog_track where track_id=0 "
      rs.open sql, conn, 1, 3
      rs.addNew()
      rs("blog_id") = blog_id
      rs("content_id") = content_id
      rs("url") = url
      rs("title") = title
      rs("excerpt") = excerpt
      rs("host_name") =  host_name
      rs("host_url") = host_url
      rs.update()
      
      track_id = rs("track_id")
      rs.close()
      
      sql = " update blog_content set track_count=track_count+1 where content_id=" & content_id
      conn.execute(sql)
      
      call blogItem.reload(content_id)  
    
%>
<response>
<error>0</error>
</response>
<%
else

%>
<response>
<error>1</error>
<message><%=err_msg%></message>
</response>
<%    

end if
closeDB()

%>
<!--#include file="inc/end.asp" -->